#ifndef __GD32E23x_HAL_TM1637_H__
#define __GD32E23x_HAL_TM1637_H__

#include <stdint.h>
#include <sys/_stdint.h>
#include "systick.h"

#define TM_IO_RCU           RCU_GPIOB

#define TM_SCL_PORT         GPIOB
#define TM_SCL_PIN          GPIO_PIN_10

#define TM_SDA_PORT         GPIOB
#define TM_SDA_PIN          GPIO_PIN_11

//命令定义
#define DISCTRL             0x8D //显示控制，显示开，亮度4/16
#define DISMODE             0x44 //固定地址方式写显存
#define READKEY             0x42 //读取按键寄存器
#define DISINC              0x04 //自动地址增加

#define TM_ADDR_0           0xc5 //显示地址0
#define TM_ADDR_1           0xc4 //显示地址1
#define TM_ADDR_2           0xc3 //显示地址2
#define TM_ADDR_3           0xc2 //显示地址3
#define TM_ADDR_4           0xc1 //显示地址4
#define TM_ADDR_5           0xc0 //显示地址5

typedef struct {
    void (*init)(void);         //初始化    
    uint8_t (*read_key)(void);  //读取按键值
    int (*show_num)(uint8_t addr,uint8_t dec);
    int (*show_dec)(uint16_t dec);     //显示10进制数
    int (*show_string)(const char *data,int len);   //显示字符串             
    int (*show_hex)(uint16_t dec);
}tm1637_t;

extern const tm1637_t g_tm1637_;
#endif//__GD32E23x_HAL_TM1637_H__
